package com.wzcl.app.dao.repository;

import com.wzcl.app.dao.model.RefundRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface RefundRequestRepository extends JpaRepository<RefundRequest,Integer>, JpaSpecificationExecutor<RefundRequest> {
    @Query(value = "update RefundRequest r set r.auditState = ?1, r.message = ?2 where r.orderNo = ?3")
    @Modifying
    @Transactional
    void updateAuditStateByOrderNumber(Integer auditState, String message, String orderNumber);

    @Query(value = "select r from RefundRequest r where r.orderNo = ?1")
    RefundRequest findByOrderNumber(String orderNumber);
}
